//买卖股票的最佳时机
//https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/description/
class Solution {
public:
    int maxProfit(vector<int>& prices) 
    {
        int n = prices.size();
        if(n == 1) return 0;

        int Max = 0;
        int Min = prices[0];
        for(int i = 1; i < n; i++)
        {
            if(prices[i] >= Min)
            {
                Max = max(Max,prices[i] - Min);
            }
            else
            {
                Min = prices[i];
            }
        }

        return Max;
    }
};